
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>4.1引用计数表 · zhoufei-iosknowledges</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhoufei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="4.2.html" />
    
    
    <link rel="prev" href="4.html" />
    

    
        <link rel="shortcut icon" href='../../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../source/images/favicon.jpg' type="image/x-icon">
    
    
        <link rel="apple-touch-icon" href='../../source/images/apple-touch-icon.jpg'>
    
    
        
        <link rel="apple-touch-icon" sizes="120x120" href="../../source/images/apple-touch-icon.jpg">
        
        <link rel="apple-touch-icon" sizes="180x180" href="../../source/images/apple-touch-icon.jpg">
        
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"zhou415770319","repo":"iosKnowledges","type":"star","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="http://www.feiyum.cn/index/" target="_blank" class="custom-link">我的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    iOS面试题总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../ui/ui.html">
            
                <a href="../ui/ui.html">
            
                    
                    1、UI视图相关面试题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../ui/UITableview.html">
            
                <a href="../ui/UITableview.html">
            
                    
                    1.1UITableview相关面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../ui/shujutongbu.html">
            
                <a href="../ui/shujutongbu.html">
            
                    
                    1.2数据源同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../ui/shijianchuandi.html">
            
                <a href="../ui/shijianchuandi.html">
            
                    
                    1.3UI事件传递与响应
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../ui/tuxiangxianshi.html">
            
                <a href="../ui/tuxiangxianshi.html">
            
                    
                    1.4UI图像显示原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../ui/kadundiaozheng.html">
            
                <a href="../ui/kadundiaozheng.html">
            
                    
                    1.5UI卡顿掉帧原因
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../ui/yibuhuizhi.html">
            
                <a href="../ui/yibuhuizhi.html">
            
                    
                    1.6异步绘制原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../ui/lipingxuanran.html">
            
                <a href="../ui/lipingxuanran.html">
            
                    
                    1.7离屏渲染
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../oc/2.html">
            
                <a href="../oc/2.html">
            
                    
                    2、OC语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../oc/2.1.html">
            
                <a href="../oc/2.1.html">
            
                    
                    2.1OC相关面试题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../oc/2.2.html">
            
                <a href="../oc/2.2.html">
            
                    
                    2.2分类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../oc/2_4.html">
            
                <a href="../oc/2_4.html">
            
                    
                    2.4扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../oc/2.5.html">
            
                <a href="../oc/2.5.html">
            
                    
                    2.5代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../oc/2.6.html">
            
                <a href="../oc/2.6.html">
            
                    
                    2.6通知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../oc/2.7.html">
            
                <a href="../oc/2.7.html">
            
                    
                    2.7KVO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../oc/2.8.html">
            
                <a href="../oc/2.8.html">
            
                    
                    2.8KVC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../oc/2.9.html">
            
                <a href="../oc/2.9.html">
            
                    
                    2.9属性关键字
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../runtime/3.html">
            
                <a href="../runtime/3.html">
            
                    
                    3、Runtime
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../runtime/3.1.html">
            
                <a href="../runtime/3.1.html">
            
                    
                    3.1对象、类对象、元类对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../runtime/3.2.html">
            
                <a href="../runtime/3.2.html">
            
                    
                    3.2消息传递机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../runtime/3.3.html">
            
                <a href="../runtime/3.3.html">
            
                    
                    3.3消息转发流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../runtime/3.4.html">
            
                <a href="../runtime/3.4.html">
            
                    
                    3.4Method-Swizzling
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="4.html">
            
                <a href="4.html">
            
                    
                    4、内存
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.5.1" data-path="4.1.html">
            
                <a href="4.1.html">
            
                    
                    4.1引用计数表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="4.2.html">
            
                <a href="4.2.html">
            
                    
                    4.2弱引用表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="4.3.html">
            
                <a href="4.3.html">
            
                    
                    4.3ARC、MRC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="4.4.html">
            
                <a href="4.4.html">
            
                    
                    4.4循环引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="4.5.html">
            
                <a href="4.5.html">
            
                    
                    4.5内存管理
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../block/5.html">
            
                <a href="../block/5.html">
            
                    
                    5、Block
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../block/5.1.html">
            
                <a href="../block/5.1.html">
            
                    
                    5.1Block本质
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../block/5.2.html">
            
                <a href="../block/5.2.html">
            
                    
                    5.2截获变量特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../block/5.3.html">
            
                <a href="../block/5.3.html">
            
                    
                    5.3内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../block/5.4.html">
            
                <a href="../block/5.4.html">
            
                    
                    5.4循环引用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../duoxiancheng/6.html">
            
                <a href="../duoxiancheng/6.html">
            
                    
                    6、多线程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../duoxiancheng/6.1.html">
            
                <a href="../duoxiancheng/6.1.html">
            
                    
                    6.1GCD、nsoperation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../duoxiancheng/6.2.html">
            
                <a href="../duoxiancheng/6.2.html">
            
                    
                    6.2资源共享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../duoxiancheng/6.3.html">
            
                <a href="../duoxiancheng/6.3.html">
            
                    
                    6.3线程同步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../duoxiancheng/6.4.html">
            
                <a href="../duoxiancheng/6.4.html">
            
                    
                    6.4SpinLock等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../runloop/7.md">
            
                <span>
            
                    
                    7、RunLoop
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../runloop/7.1.md">
            
                <span>
            
                    
                    7.1事件循环
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../runloop/7.2.md">
            
                <span>
            
                    
                    7.2用户态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../runloop/7.3.md">
            
                <span>
            
                    
                    7.3核心态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../runloop/7.4.md">
            
                <span>
            
                    
                    7.4常驻线程
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../network/8.md">
            
                <span>
            
                    
                    8、网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../network/8.1.md">
            
                <span>
            
                    
                    8.1HTTPS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../network/8.2.md">
            
                <span>
            
                    
                    8.2对称加密算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../network/8.3.md">
            
                <span>
            
                    
                    8.3非对称加密
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../network/8.4.md">
            
                <span>
            
                    
                    8.4DNS解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../network/8.5.md">
            
                <span>
            
                    
                    8.5HTTP、TCP
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >4.1引用计数表</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;"><b></b>&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;</a></li></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;"><a name="&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;" class="plugin-anchor" href="#&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x8868;</h2>
<p>Objecttive-C&#x4F7F;&#x7528;&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x6765;&#x8FDB;&#x884C;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#x3002;
 &#x7136;&#x540E;&#xFF0C;&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x5176;&#x5B9E;&#x662F;&#x4E0D;&#x51C6;&#x7684;&#x3002;</p>
<h6 id="&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x539F;&#x7406;&#xFF1A;"><a name="&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x539F;&#x7406;&#xFF1A;" class="anchor-navigation-ex-anchor" href="#&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x539F;&#x7406;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x539F;&#x7406;&#xFF1A;" class="plugin-anchor" href="#&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x539F;&#x7406;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x539F;&#x7406;&#xFF1A;</h6>
<pre><code>retain &#x9012;&#x589E;&#x5F15;&#x7528;&#x8BA1;&#x6570;
release &#x9012;&#x51CF;&#x5F15;&#x7528;&#x8BA1;&#x6570;
autorelease &#x6E05;&#x7406;&#x300C;&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x300D;&#x65F6;&#xFF0C;&#x5728;&#x9012;&#x51CF;&#x4FDD;&#x7559;&#x8BA1;&#x6570;
</code></pre><h6 id="&#x5173;&#x4E8E;&#x8FC7;&#x65E9;&#x91CA;&#x653E;&#x5BF9;&#x8C61;&#x800C;&#x5BFC;&#x81F4;&#x7684;bug&#xFF1A;"><a name="&#x5173;&#x4E8E;&#x8FC7;&#x65E9;&#x91CA;&#x653E;&#x5BF9;&#x8C61;&#x800C;&#x5BFC;&#x81F4;&#x7684;bug&#xFF1A;" class="anchor-navigation-ex-anchor" href="#&#x5173;&#x4E8E;&#x8FC7;&#x65E9;&#x91CA;&#x653E;&#x5BF9;&#x8C61;&#x800C;&#x5BFC;&#x81F4;&#x7684;bug&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5173;&#x4E8E;&#x8FC7;&#x65E9;&#x91CA;&#x653E;&#x5BF9;&#x8C61;&#x800C;&#x5BFC;&#x81F4;&#x7684;bug&#xFF1A;" class="plugin-anchor" href="#&#x5173;&#x4E8E;&#x8FC7;&#x65E9;&#x91CA;&#x653E;&#x5BF9;&#x8C61;&#x800C;&#x5BFC;&#x81F4;&#x7684;bug&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5173;&#x4E8E;&#x8FC7;&#x65E9;&#x91CA;&#x653E;&#x5BF9;&#x8C61;&#x800C;&#x5BFC;&#x81F4;&#x7684;bug&#xFF1A;</h6>
<p>&#x82E5;&#x56E0;&#x67D0;&#x4E9B;&#x539F;&#x56E0;&#xFF0C;&#x5BF9;&#x8C61;&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x964D;&#x81F3;0&#xFF0C;&#x90A3;&#x4E48;&#x5BF9;&#x8C61;&#x6240;&#x5728;&#x7684;&#x5185;&#x5B58;&#x4E5F;&#x8BB8;&#x4F1A;&#x56DE;&#x6536;&#xFF0C;&#x8FD9;&#x6837;&#x7684;&#x8BDD;&#xFF0C;&#x5176;&#x4ED6;&#x65B9;&#x6CD5;&#x5728;&#x8C03;&#x7528;&#x6B64;&#x5BF9;&#x8C61;&#x53EF;&#x80FD;&#x5C31;&#x4F7F;&#x7A0B;&#x5E8F;&#x5D29;&#x6E83;&#x4E86;&#xFF0C;&#x8FD9;&#x91CC;&#x8BF4;&#x662F;&#x53EF;&#x80FD;&#xFF0C;&#x56E0;&#x4E3A;&#x5BF9;&#x8C61;&#x6240;&#x5360;&#x7528;&#x7684;&#x5185;&#x5B58;&#x5728;&#x300E;&#x89E3;&#x9664;&#x5206;&#x914D;(deallocated)&#x4E4B;&#x540E;&#xFF0C;&#x53EA;&#x662F;&#x653E;&#x56DE;&#x300C;&#x53EF;&#x7528;&#x5185;&#x5B58;&#x6C60;&#xFF08;avaiable pool&#xFF09;&#x300D;&#x300F;&#x5982;&#x679C;&#x5176;&#x4ED6;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x6B64;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;&#x5C1A;&#x672A;&#x590D;&#x5199;&#x5BF9;&#x8C61;&#x5185;&#x5B58;&#xFF0C;&#x90A3;&#x4E48;&#x8BE5;&#x5BF9;&#x8C61;&#x4ECD;&#x7136;&#x6709;&#x6548;&#xFF0C;&#x8FD9;&#x65F6;&#x7A0B;&#x5E8F;&#x4E0D;&#x4F1A;&#x5D29;&#x6E83;&#x3002;    &#x8FD9;&#x4E48;&#x8BF4;&#xFF0C;&#x53EF;&#x80FD;&#x4E0D;&#x592A;&#x597D;&#x61C2;&#xFF0C;&#x4E0A;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code>NSMutableArray *array = [NSMutableArray array];
NSNumber *number = [[NSNumber alloc] initWithInt:1024];
[array addObject:number];
[number release];
NSLog(@&quot;number = %@&quot;,number);
&#x8FD9;&#x91CC;&#x9762;&#x6211;&#x7528;NSNumber&#x5176;&#x5B9E;&#x6709;&#x70B9;&#x4E0D;&#x539A;&#x9053;&#xFF0C;&#x4F46;&#x662F;&#x4E3B;&#x8981;&#x8FD8;&#x662F;&#x8BA9;&#x60A8;&#x8BB0;&#x4F4F;&#x4E0A;&#x9762;&#x8BF4;&#x7684;&#x3002;
</code></pre><h6 id="&#x5C5E;&#x6027;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#xFF1A;"><a name="&#x5C5E;&#x6027;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#xFF1A;" class="anchor-navigation-ex-anchor" href="#&#x5C5E;&#x6027;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5C5E;&#x6027;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#xFF1A;" class="plugin-anchor" href="#&#x5C5E;&#x6027;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5C5E;&#x6027;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#xFF1A;</h6>
<p>&#x8BF4;&#x4E00;&#x4E0B;set&#x65B9;&#x6CD5;&#x4E2D;&#x7684;&#x5148;&#x50A8;&#x5B58;&#x65B0;&#x503C;&#xFF0C;&#x518D;&#x91CA;&#x653E;&#x65E7;&#x503C;&#x548C;&#x5148;&#x91CA;&#x653E;&#x65E7;&#x503C;&#x5728;&#x50A8;&#x5B58;&#x65B0;&#x503C;&#x7684;&#x533A;&#x522B;&#xFF1A;
 &#x9996;&#x5148;&#xFF0C;&#x5148;&#x50A8;&#x5B58;&#x65B0;&#x503C;&#xFF0C;&#x518D;&#x91CA;&#x653E;&#x65E7;&#x503C;&#x66F4;&#x4E25;&#x8C28;&#x4E00;&#x4E9B;&#x3002;
 &#x4E25;&#x8C28;&#x5728;&#x54EA;&#x91CC;&#x5462;&#xFF1F;</p>
<pre><code>setNumber:&#xFF08;NSNumber *&#xFF09;number{

    [number retain];
    [number release];
    _number = number;
}

&#x5148;&#x8BF4;&#x4E00;&#x4E0B;&#xFF0C;NSNumber&#x8FD9;&#x4E2A;&#x7C7B;&#x578B;&#x5F88;&#x7279;&#x6B8A;&#xFF1A;
NSNumber *number1 = [[...alloc]int:11];
NSNumber *number2 = [[...alloc]int:11];
&#x8FD9;&#x4E2A;number1&#x548C;number2&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#x662F;&#x76F8;&#x540C;&#x7684;&#x3002;
&#x5173;&#x4E8E;NSNumber&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x4E86;&#x89E3;&#x7684;&#x8BDD;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;&#x770B;&#xFF0C;&#x5510;&#x5DE7;&#x524D;&#x8F88;&#x5199;&#x7684;&#x8FD9;&#x4E24;&#x7BC7;&#x6587;&#x7AE0;&#xFF1A;
http://www.devtang.com/blog/2014/05/30/understand-tagged-pointer/
http://blog.xcodev.com/archives/tagged-pointer-and-64-bit/


&#x7ECF;jocker&#x63D0;&#x9192;&#xFF0C;setter&#x65B9;&#x6CD5;&#x5EFA;&#x8BAE;&#x8FD9;&#x4E48;&#x5199;
- (void)setBlackBoard:(Blackboard *)blackBoard
{
    if (_blackBoard != blackBoard) {
       [_blackBoard release];
       _blackBoard = [blackBoard retain];
  }
}
</code></pre><p>&#x8DD1;&#x504F;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x5F80;&#x56DE;&#x8BF4;:
 &#x5982;&#x679C;&#xFF0C;&#x65B0;&#x65E7;&#x4E24;&#x503C;&#x6307;&#x5411;&#x540C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x90A3;&#x4E48;&#x82E5;&#x5148;&#x6267;&#x884C;&#x91CA;&#x653E;&#xFF0C;&#x5C31;&#x53EF;&#x80FD;&#x5BFC;&#x81F4;&#x7CFB;&#x7EDF;&#x5C06;&#x6B64;&#x5BF9;&#x8C61;&#x6C38;&#x4E45;&#x56DE;&#x6536;&#xFF0C;&#x800C;&#x540E;&#x7EED;&#x7684;&#x4FDD;&#x7559;&#x64CD;&#x4F5C;&#x5BF9;&#x5DF2;&#x7ECF;&#x56DE;&#x6536;&#x7684;&#x5BF9;&#x8C61;&#x662F;&#x65E0;&#x7528;&#x7684;&#xFF0C;&#x8FD9;&#x4E2A;&#x5B9E;&#x4F8B;&#x53D8;&#x91CF;&#x5C31;&#x53D8;&#x6210;&#x4E86;&#x60AC;&#x6302;&#x6307;&#x9488;&#x3002;</p>
<h5 id="&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF1A;"><a name="&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF1A;" class="anchor-navigation-ex-anchor" href="#&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF1A;" class="plugin-anchor" href="#&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF1A;</h5>
<p>&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x548C;release&#x7684;&#x533A;&#x522B;&#xFF1A;
 release&#x4F1A;&#x7ACB;&#x523B;&#x9012;&#x51CF;&#x5BF9;&#x8C61;&#x7684;&#x4FDD;&#x7559;&#x8BA1;&#x6570;&#xFF0C;&#x53EF;&#x80FD;&#x4EE4;&#x7CFB;&#x7EDF;&#x7ACB;&#x5373;&#x56DE;&#x6536;&#x5B83;&#xFF0C;&#x6CE8;&#x610F;&#x662F;&#x53EF;&#x80FD;&#x3002;
 &#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x5462;&#xFF0C;&#x5047;&#x5982;&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x4F1A;&#x7A0D;&#x540E;&#x9012;&#x51CF;&#xFF0C;&#x8FD9;&#x4E2A;&#x7A0D;&#x540E;&#x4E00;&#x822C;&#x6307;&#x4E0B;&#x4E00;&#x6B21;<code>event loop</code>&#x7684;&#x65F6;&#x5019;,&#x6CE8;&#x610F;&#x8FD9;&#x91CC;&#x662F;&#x4E00;&#x822C;&#xFF0C;&#x4E0D;&#x662F;&#x8BF4;&#x7EDD;&#x5BF9;&#x3002;
 &#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x591A;&#x7528;&#x4E8E;&#x8DE8;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#xFF0C;&#x4E66;&#x4E0A;&#x7684;&#x539F;&#x8BDD;&#x8BF4;&#xFF0C;<code>&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x53EF;&#x4EE5;&#x4FDD;&#x8BC1;&#x5BF9;&#x8C61;&#x5728;&#x8DE8;&#x8D8A;&#x300C;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x8FB9;&#x754C;&#x300D;(method call boundary)&#x540E;&#x4E00;&#x5B9A;&#x5B58;&#x6D3B;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;&#x91CA;&#x653E;&#x64CD;&#x4F5C;&#x4F1A;&#x5728;&#x6E05;&#x7A7A;&#x6700;&#x5916;&#x5C42;&#x7684;&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#x65F6;&#x6267;&#x884C;&#xFF0C;&#x9664;&#x975E;&#x4F60;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x81EA;&#x52A8;&#x91CA;&#x653E;&#x6C60;&#xFF0C;&#x5426;&#x5219;&#x8FD9;&#x4E2A;&#x65F6;&#x673A;&#x6307;&#x7684;&#x5C31;&#x662F;&#x5F53;&#x524D;&#x7EBF;&#x7A0B;&#x7684;&#x4E0B;&#x4E00;&#x6B21;&#x4E8B;&#x4EF6;&#x5FAA;&#x73AF;&#x3002;</code></p>
<h5 id="&#x5FAA;&#x73AF;&#x5F15;&#x7528;"><a name="&#x5FAA;&#x73AF;&#x5F15;&#x7528;" class="anchor-navigation-ex-anchor" href="#&#x5FAA;&#x73AF;&#x5F15;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x5FAA;&#x73AF;&#x5F15;&#x7528;" class="plugin-anchor" href="#&#x5FAA;&#x73AF;&#x5F15;&#x7528;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5FAA;&#x73AF;&#x5F15;&#x7528;</h5>
<p>A&#x5BF9;&#x8C61;&#x4E2D;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x662F;B&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;B&#x5BF9;&#x8C61;&#x4E2D;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x662F;C&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;C&#x5BF9;&#x8C61;&#x4E2D;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x662F;A&#x7684;&#x5B9E;&#x4F8B;&#x3002;&#x8FD9;&#x5C31;&#x6784;&#x6210;&#x4E86;&#x5FAA;&#x73AF;&#x5F15;&#x7528;&#x3002;
 &#x5F53;&#x7136;&#xFF0C;&#x8FD9;&#x4E48;&#x8BF4;&#x662F;&#x4E0D;&#x4E25;&#x8C28;&#x7684;&#xFF0C;&#x6539;&#x4E00;&#x6539;&#xFF1A;
 A&#x5F3A;&#x5F15;&#x7528;&#x4E86;b&#xFF0C;B&#x5F3A;&#x5F15;&#x7528;&#x4E86;c&#xFF0C;C&#x5F3A;&#x5F15;&#x7528;&#x4E86;a&#xFF0C;&#x8FD9;&#x5C31;&#x6784;&#x6210;&#x4E86;&#x5FAA;&#x73AF;&#x5F15;&#x7528;&#x3002;
 &#x89E3;&#x51B3;&#x7684;&#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#xFF1A;
 1&#x3001;&#x6539;&#x5F3A;&#x5F15;&#x7528;&#x4E3A;&#x5F31;&#x5F15;&#x7528;&#x3002;
 2&#x3001;&#x4ECE;&#x5916;&#x5C4A;&#x547D;&#x4EE4;&#x5FAA;&#x73AF;&#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x4E0D;&#x5728;&#x5F15;&#x7528;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;</p>
<h5 id="&#x91CA;&#x653E;&#x7684;&#x65F6;&#x673A;&#xFF1A;"><a name="&#x91CA;&#x653E;&#x7684;&#x65F6;&#x673A;&#xFF1A;" class="anchor-navigation-ex-anchor" href="#&#x91CA;&#x653E;&#x7684;&#x65F6;&#x673A;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a><a name="&#x91CA;&#x653E;&#x7684;&#x65F6;&#x673A;&#xFF1A;" class="plugin-anchor" href="#&#x91CA;&#x653E;&#x7684;&#x65F6;&#x673A;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x91CA;&#x653E;&#x7684;&#x65F6;&#x673A;&#xFF1A;</h5>
<p>&#x672C;&#x6587;&#x591A;&#x6B21;&#x8BF4;&#x4E86;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x56DE;&#x6536;&#x5185;&#x5B58;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x56DE;&#x6536;&#x5185;&#x5B58;&#xFF0C;&#x5185;&#x5B58;&#x7A76;&#x7ADF;&#x5728;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x56DE;&#x6536;&#x5462;&#xFF1A;</p>
<p>&#x51E0;&#x53E5;&#x8BDD;:</p>
<pre><code>1.&#x91CA;&#x653E;&#x64CD;&#x4F5C;&#x662F;RunLoop&#x7BA1;&#x7406;&#x7684; &#x8981;RunLoop&#x8FD0;&#x884C;&#x5230;&#x91CA;&#x653E;&#x7684;&#x65F6;&#x5019;&#x624D;&#x4F1A;&#x88AB;&#x91CA;&#x653E;&#xFF0C;RunLoopEnterwaiting&#x7684;&#x65F6;&#x5019;&#x5C31;&#x91CA;&#x653E;&#x4E86;
2.&#x91CA;&#x653E;&#x662F;&#x7EDF;&#x4E00;&#x5904;&#x7406;&#x7684; &#x4E0D;&#x662F;&#x67D0;&#x4E2A;&#x5BF9;&#x8C61;&#x4E3A;&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x4E3A;0&#x5C31;&#x628A;&#x4ED6;&#x7ACB;&#x5373;&#x91CA;&#x653E;&#x4E86;&#x3002;
3.CoreFoundation&#x5BF9;&#x8C61;&#x548C;OC&#x5BF9;&#x8C61;&#x4E92;&#x8F6C;&#x7684;&#x91CA;&#x653E;&#x95EE;&#x9898; CF&#x5BF9;&#x8C61;&#x662F;&#x4E0D;&#x652F;&#x6301;ARC&#x7684; &#x8981;&#x81EA;&#x5DF1;&#x7BA1;&#x7406;
</code></pre><p>&#x53C2;&#x8003;&#xFF1A;</p>
<pre><code>Effective Objective-2.0 29Tip
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="4.html" class="navigation navigation-prev " aria-label="Previous page: 4、内存">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="4.2.html" class="navigation navigation-next " aria-label="Next page: 4.2弱引用表">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"4.1引用计数表","level":"1.5.1","depth":2,"next":{"title":"4.2弱引用表","level":"1.5.2","depth":2,"path":"md/neicun/4.2.md","ref":"md/neicun/4.2.md","articles":[]},"previous":{"title":"4、内存","level":"1.5","depth":1,"path":"md/neicun/4.md","ref":"md/neicun/4.md","articles":[{"title":"4.1引用计数表","level":"1.5.1","depth":2,"path":"md/neicun/4.1.md","ref":"md/neicun/4.1.md","articles":[]},{"title":"4.2弱引用表","level":"1.5.2","depth":2,"path":"md/neicun/4.2.md","ref":"md/neicun/4.2.md","articles":[]},{"title":"4.3ARC、MRC","level":"1.5.3","depth":2,"path":"md/neicun/4.3.md","ref":"md/neicun/4.3.md","articles":[]},{"title":"4.4循环引用","level":"1.5.4","depth":2,"path":"md/neicun/4.4.md","ref":"md/neicun/4.4.md","articles":[]},{"title":"4.5内存管理","level":"1.5.5","depth":2,"path":"md/neicun/4.5.md","ref":"md/neicun/4.5.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","splitter","expandable-chapters-small","anchors","github","github-buttons","donate","sharing-plus","anchor-navigation-ex","favicon","livereload"],"styles":{"website":"./styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"github":{"url":"https://github.com/zhou415770319"},"livereload":{},"splitter":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"../../img/alipay.JPG","alipayText":" ","button":"赞赏","title":"","wechat":"","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"favicon":{"shortcut":"./source/images/favicon.jpg","bookmark":"./source/images/favicon.jpg","appleTouch":"./source/images/apple-touch-icon.jpg","appleTouchMore":{"120x120":"./source/images/apple-touch-icon.jpg","180x180":"./source/images/apple-touch-icon.jpg"}},"github-buttons":{"buttons":[{"user":"zhou415770319","repo":"iosKnowledges","type":"star","size":"small","count":true}]},"expandable-chapters-small":{},"sharing":{"qq":false,"all":["google","facebook","weibo","twitter","qq","qzone","linkedin","pocket"],"douban":false,"facebook":false,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"anchors":{}},"theme":"default","author":"zhoufei","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"zhoufei-iosknowledges","language":"zh-hans","links":{"sidebar":{"我的博客":"http://www.feiyum.cn/index/"}},"gitbook":"3.2.3","description":"ios面试知识点总结"},"file":{"path":"md/neicun/4.1.md","mtime":"2019-05-03T14:40:51.309Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-03T14:51:39.741Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

